package com.twt.sys.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.twt.sys.base.BaseController;
import com.twt.common.pojo.Result;
import com.twt.common.utils.Assert;
import com.twt.model.system.vo.SysDictQueryVo;
import com.twt.sys.base.BaseService;
import com.twt.sys.service.SysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.twt.model.system.entity.SysDict;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sys/dict")
public class SysDictController extends BaseController<SysDict> {
    @Autowired
    private SysDictService sysDictService;

    @Override
    protected BaseService getBaseService() {
        return sysDictService;
    }


    @GetMapping("/query/page/{currentPage}/{pageSize}")
    public Result queryPageSysDict(@PathVariable("currentPage") long currentPage, @PathVariable("pageSize") long pageSize, SysDict queryVo) {
        Page<SysDict> page = new Page<>();
        page.setCurrent(currentPage);
        page.setSize(pageSize);
        Page<SysDict> sysDictPage = sysDictService.queryPageByQueryVo(page, queryVo);
        return Result.ok(sysDictPage);
    }

    @Deprecated
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        Assert.isBlank(id, "id 不能为空！");
        sysDictService.removeById(id);
        return Result.ok();
    }

    @GetMapping("/query/all")
    public Result queryAll() {
        Map<String,Object> sysDictInfoVoList = this.sysDictService.queryAllDict();
        return Result.ok(sysDictInfoVoList);
    }
}
